<template>
  <el-dialog :title="auditStatus==0?'审核':'查看'" :close-on-click-modal="false" :visible.sync="visible">
    <el-form :model="dataForm" :disabled="auditStatus!=0?true:false" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
      <el-form-item label="审核">
        <el-radio-group v-model="dataForm.audit_status">
          <el-radio label="1">审核通过</el-radio>
          <el-radio label="2">审核不通过</el-radio>
        </el-radio-group>
      </el-form-item>
      <!--      <el-form-item v-if="is_pass==2" label="理由" prop="type">
        <el-select v-model="value" placeholder="请选择">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.name"
              :value="item.value">
            </el-option>
          </el-select>
      </el-form-item> -->
      <el-form-item v-if="dataForm.audit_status==2" label="其他">
        <el-input type="textarea" :rows="3" maxlength="50" placeholder="" v-model="dataForm.audit_remark"></el-input>
      </el-form-item>
    </el-form>
    <!-- //点击 查看进来，不显示按钮 -->
    <span slot="footer" class="dialog-footer" v-if="auditStatus == 0">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import {
  treeDataTranslate
} from '@/utils'
import seviceApi from '@/api/serviceApi.js'
export default {
  data () {
    return {
      visible: false,
      dataForm: {
        id: '',
        audit_status: 0,
        audit_remark: ''
      },
      auditStatus: 0
    }
  },

  methods: {
    init (id, auditStatus) {
      this.dataForm.id = id
      this.visible = true
      this.$nextTick(() => {
        this.$refs['dataForm'].resetFields()
      })
      this.auditStatus = auditStatus
      this.dataForm = {
        id: id,
        audit_status: 0,
        audit_remark: ''
      }
    },
    // 提交
    dataFormSubmit () {
      var param = {
        id: this.dataForm.id,
        audit_status: parseInt(this.dataForm.audit_status),
        audit_remark: this.dataForm.audit_remark
      }
      console.log(this.dataForm.id)
      if (this.dataForm.audit_status == 0) {
        this.$message('请选择审核')
      } else {
        seviceApi.getShopapplyAuditcs(param).then(res => {
          if (res && res.data.code == 200) {
            this.$message({
              showClose: true,
              message: '操作成功',
              type: 'success'
            })
            this.visible = false
            this.$emit('updataList', 1)
          }
        })
      }
    }
  }
}
</script>

<style lang="scss">
</style>
